<% import org.codehaus.groovy.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor as Events %>
<%=packageName%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <script type="text/javascript" src ="\${resource(dir:'js',file:'function.js')}">
        </script>
        <title>修改${className}</title>
    </head>
    <body>
        <div class="body">
            <h1>修改${className}</h1>
            <g:if test="\${flash.message}">
            <div class="message">\${flash.message}</div>
            </g:if>
            <g:hasErrors bean="\${${propertyName}}">
            <div class="errors">
                <g:renderErrors bean="\${${propertyName}}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
                <input type="hidden" name="id" value="\${${propertyName}?.id}" />
                <input type="hidden" name="version" value="\${${propertyName}?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        <%
                            excludedProps = ['version',
                                             'id',
                                               Events.ONLOAD_EVENT,
                                               Events.BEFORE_DELETE_EVENT,
                                               Events.BEFORE_INSERT_EVENT,
                                               Events.BEFORE_UPDATE_EVENT]
                            props = domainClass.properties.findAll { !excludedProps.contains(it.name) }
                            
                            Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
							int count = 0;
                            props.each { p ->
								cp = domainClass.constrainedProperties[p.name]
								display = (cp ? cp.display : true)        
								if(display) {
									if(count % 4 == 0){
						%>
                            <tr class="prop">
                            <% }%>
                                <td valign="middle" class="name">
                                    <label for="${p.name}">${p.naturalName}:</label>
                                </td>
                                <td valign="middle" class="value \${hasErrors(bean:${propertyName},field:'${p.name}','errors')}">
                                    ${renderEditor(p)}
                                </td>
							<%
							if(count%4==3) {
							%>
								<td></td>
								</tr>
							<%}
							count++}}%>			
							   </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><input type="submit" name="_action_update" value="修改" class="save" /></span>
                    <span class="button"><input type="submit" name="_action_delete" value="删除" class="delete"
                    onclick="return confirm('\${message(code:'default.delete.confirm')}');" /></span>
					<span class="button"><input class="formbutton" type="reset" value="重置" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
